<template>
    <div class="demo8">

        <!-- 内容部分 -->
        <div class="demo8_main">
            <noData v-if="arr1 == 0"></noData>
            <div class="list3Box">
                <checklist :options="arr1"
                           v-model="checklist"
                           @on-change="change"></checklist>
            </div>
        </div>
        <myMenu @clickBack="back"></myMenu>
    </div>
</template>
<script>
import { Checklist } from 'vux'
import myMenu from '@/commonComponents/menu'
export default {
    components: {
        Checklist,
        myMenu
    },
    data () {
        return {
            checklist: [],
            parmas: {
                allowPaging: 'false',
                business: 'GetAccidentType',
                tokenId: '',
                userId: ''
            },
            //   arr1:['物体打击','车辆伤害','机具伤害','起重伤害','高处坠落','触电','淹溺','坍塌','冒顶片帮',
            //         '透水','中毒和窒息','爆炸','放炮','其他伤害'],
            arr1: [],
            nameArr: []
        }
    },
    created () {
        this.dataArr()
    },
    mounted () {
        if (JSON.parse(window.sessionStorage.getItem('name3'))) {
            this.checklist = JSON.parse(window.sessionStorage.getItem('name3'))
        } else {
            this.checklist = ['全部']
        }
    },
    methods: {
        back () {
            window.sessionStorage.setItem('name3', JSON.stringify(this.nameArr))
        },
        change (value, label) {
            debugger
            // for(var k of label){
            //     if (k =='全部'){
            //         this.checklist=this.arr1
            //     }
            // }
            if (label.length == Number(window.sessionStorage.getItem('len'))) {
                this.checklist = this.arr1
            }
            this.nameArr = label
        },
        dataArr () {
            this.$axiosAjax.getConfigJson(this.parmas).then((res) => {
                if (res.status) {
                    if (res.data.data) {
                        this.arr1 = res.data.data
                        window.sessionStorage.setItem('len', this.arr1.length - 1)
                    }
                }
            })
        }
    }
}

</script>
<style lang="less" scoped>
.demo8 {
    width: 100%;
    height: 100%;
    .header {
        width: 100%;
        height: 40px;
        line-height: 40px;
        text-align: center;
        position: relative;
        font-size: 18px;
        background: #2269ff;
        color: #fff;
        .vux-x-icon {
            fill: cornsilk;
            position: absolute;
            left: 0;
            top: 5px;
            width: 30px;
            height: 30px;
        }
    }
    .demo8_main {
        height: 603px;
        width: 100%;
        background-color: #ebeef2;
        .list3Box {
            width: 100%;
            height: 603px;
            background-color: #fff;
            ul {
                padding: 0 10px;
                li {
                    height: 60px;
                    line-height: 60px;
                    font-size: 20px;
                    border-bottom: 1px solid #999;
                }
            }
        }
    }
    .weui-check_label {
        width: 100%;
        height: 44px;
        background-color: pink;
    }
}
</style>
